package com.itheima03;

import java.util.HashMap;
import java.util.Scanner;
import java.util.Set;

public class Test02 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入字符串:");
        String str = sc.nextLine();
        char[] chars = str.toCharArray();
        HashMap<Character,Integer>  hm = new HashMap<>();
        for (char aChar : chars) {
            if (hm.containsKey(aChar)){
                int conut = hm.get(aChar);
                conut++;
                hm.put(aChar,conut);
            }else{
                hm.put(aChar,1);
            }
        }
        //System.out.println(hm);
        Set<Character> chs = hm.keySet();
        for (Character ch : chs) {
            Integer integer = hm.get(ch);
            System.out.print(ch+"("+integer+")");
        }
        System.out.println();
        System.out.println("-------------------------------------------");
        int[] conut = new int[26];
        //System.out.println(str.charAt(0)+0);
        for (int i = 0; i < chars.length; i++) {
            char ch = chars[i];
            conut[ch - 97]++;
            }
        for (int i = 0 ,ch=97; i < conut.length; i++,ch++) {
            if (conut[i]!=0){
                System.out.print((char)ch+"("+conut[i]+")");
            }
        }
        }

    }

